@echo off
REM Usage:
REM genModel.bat database_name table_name
REM Example:
REM genModel.bat library books
REM Move the generated files from .\genModel to the corresponding service's model directory

REM Check if both database name and table name are provided
if "%1"=="" (
    echo Usage: genModel.bat database_name table_name
    echo Example: genModel.bat library books
    exit /b 1
)

REM Database configuration
set host=113.44.153.140
set port=5432
set dbname=%1
set username=postgres
set passwd=PaperTrust2024

REM Table name to generate
set tables=%2

REM Directory to generate model files
set modeldir=..\model

echo Starting to create table: %tables% in database: %dbname%
goctl model pg datasource -url="postgres://%username%:%passwd%@%host%:%port%/%dbname%" -table="%tables%" -dir="%modeldir%" -cache=true --style=goZero

echo %1:%2 generated successfully.